﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using JobShopModel.Model;
using JobShopModel.Model.FactoryLvl;

namespace JobShopModel.GraphicInterface
{
    public partial class Configuration : Form
    {
        public int[] numMachines;
        public int Days;
        
        public Configuration(MainFrm owner)
        {
            InitializeComponent();

            Days = 10;
            StationNumericUpDown1.Value = owner.MachineArray[0];
            StationNumericUpDown2.Value = owner.MachineArray[1];
            StationNumericUpDown3.Value = owner.MachineArray[2];
            StationNumericUpDown4.Value = owner.MachineArray[3];
            StationNumericUpDown5.Value = owner.MachineArray[4];
                  
            LogPriority.Items.Add(ItemPriorities.SLOW);            
            LogPriority.Items.Add(ItemPriorities.NORMAL);
            LogPriority.Items.Add(ItemPriorities.CREATION);
            LogPriority.Items.Add(ItemPriorities.URGENT);
            LogPriority.Items.Add(ItemPriorities.NONE);

            DurationNumericUpDown.Value = (Decimal)owner.TimeSimulation.Days;
            LogPriority.SelectedItem = owner.Priority;


        }

        private void SaveButton_Click(object sender, EventArgs e)
        {
            ((MainFrm)Owner).TimeSimulation = new Time((int)DurationNumericUpDown.Value);
            int[] array = {(int)StationNumericUpDown1.Value,
                            (int)StationNumericUpDown2.Value,
                            (int)StationNumericUpDown3.Value,
                           (int) StationNumericUpDown4.Value,
                           (int) StationNumericUpDown5.Value};
            ((MainFrm)Owner).MachineArray = array;
            ((MainFrm)Owner).Priority = (ItemPriorities)LogPriority.SelectedItem;
            ((MainFrm)Owner).AutoWrite = autoSave.Checked;
                
                //ChangeLoggerProperties((ItemPriorities)LogPriority.SelectedItem, autoSave.Checked);
            
            Close();
        }

        private void DefaultButton_Click(object sender, EventArgs e)
        {
            DurationNumericUpDown.Value = 365;

            StationNumericUpDown1.Value = 3;
            StationNumericUpDown2.Value = 2;
            StationNumericUpDown3.Value = 4;
            StationNumericUpDown4.Value = 3;
            StationNumericUpDown5.Value = 1;

            LogPriority.SelectedItem = ItemPriorities.NORMAL;
            autoSave.Checked = false;

        }

        private void SimCancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }

    }
}
